﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ContractorTimesheet.DataModel;

namespace ContractorTimesheet.Models
{
    public class HolidayEditorModel
    {
        public HolidayEditorModel()
        {
            ResetNewHoliday();
            
            Holidays = new List<Holiday>();
        }

        public string NewYear { get; set; }

        public string NewMonth { get; set; }

        public string NewDay { get; set; }

        public string NewDescription { get; set; }

        public List<Holiday> Holidays { get; set; }

        public void ResetNewHoliday()
        {
            NewYear = string.Empty;

            NewMonth = string.Empty;

            NewDay = string.Empty;
            
            NewDescription = string.Empty;
        }

        public HolidayEditorModel SortByDateDescending()
        {
            HolidayEditorModel model = new HolidayEditorModel();
            model.NewYear = NewYear;
            model.NewMonth = NewMonth;
            model.NewDay = NewDay;
            model.NewDescription = NewDescription;
            model.Holidays = Holidays.OrderByDescending(h => h.Year).ThenByDescending(h => h.Month).ThenByDescending(h => h.Day).ToList();

            return model;
        }

    }
}